package main;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-03-11
 * Time: 12:29
 */
public class person {
    private String name;
    private int age;

    public person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void keepPet(Animal animal , String something){
        if (animal instanceof Dog){
            System.out.println("年龄为"+this.age+"的"+this.name+"养了一只颜色为"+animal.getColor()+"的狗");
            animal.eat(something);
            animal = (Dog)animal;
            ((Dog) animal).lookhome();
        }else {
            System.out.println("年龄为"+this.age+"的"+this.name+"养了一只颜色为"+animal.getColor()+"的猫");
            animal.eat(something);
            animal = (Cat)animal;
            ((Cat) animal).catchMouse();
        }
    }

}
